# include "graph.h"
# include <stdio.h>

int main (int argc, char *argv[]) {
	int n,j,a,b,m;
	Graph *g;
	int i; LinkedList *lst;
	int *ad;
	if (argc < 2) printf("SINTAXE: cmd <Num Nodos>\n");
	else {
		n = atoi(argv[1]);
		ad = (int *) malloc(sizeof(int)*n);
		for (i=0;i<n;i++) ad[i] = 0;
		printf("Introduza pares de nodos (indices) para definir o grafo (min 0 - max %d):\n",n-1);
		g = newGraph(n);
		
		while (scanf("%d %d",&a,&b)!=EOF) {
			if (createEdge(g,a,b)) printf("CRIADO\n");
		}
		printf("\nRecolher dados\n\n");
		lst = getConnectedSubGraphs(g);
		if (lst) {
			n = listSize(lst);
			a = 1;
			while (lst) {
				g = getData(lst);
				for (i=0;i<g->nodes;i++) printf("Nodo %d pertence ao %dº subgrafo\n",g->label[i],a);
				lst = lst->next;
				a++;
			}
		}
		else n = 0;
		printf("Tem %d subgrafos\n",n);
	}
	return 0;
}
